package com.gzx.risk.core.service;

import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
import com.gzx.risk.core.utils.CommonWechatUtil;
import com.gzx.risk.core.utils.WechatBotKeyEnum;
import com.gzx.risk.core.utils.WechatNotificationType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.List;

@Service
public class WeChatService {
	@Value("${spring.profiles.active}")
	private String env;

	public void sendMessage(WechatBotKeyEnum wechatBotKeyEnum, WechatNotificationType type, String title,
			List<String> noticeUserList, List<String> contents) {
		if ("prod".equals(env)) {
			CommonWechatUtil.sendMessageTool(wechatBotKeyEnum, type, title, noticeUserList, contents);
		} else {
			CommonWechatUtil.sendMessageTool(WechatBotKeyEnum.TEST, type, title, noticeUserList, contents);
		}
	}

    public void sendImage(WechatBotKeyEnum wechatBotKeyEnum, InputStream fileStream) throws Exception {
        if ("prod".equals(env)) {
            CommonWechatUtil.sendImageTool(wechatBotKeyEnum, fileStream);
        } else {
            CommonWechatUtil.sendImageTool(WechatBotKeyEnum.TEST, fileStream);
        }
    }

    public void sendNotifyReportTemp(InputStream images, List<String> users) throws Exception {
        if ("prod".equals(env)) {
            // 正式暂时不发
        }else {
            CommonWechatUtil.sendMessageTool(WechatBotKeyEnum.TEST, WechatNotificationType.BLACK, "每日报告", users, Lists.newArrayList());
            CommonWechatUtil.sendImageTool(WechatBotKeyEnum.TEST, images);
        }
    }
}
